<template>
  <div class="mod-config">
    <basic-container>
      <navigationHeTong
        :sign="{ a: true, b: false, c: false, d: false, e: false, f: false }"
      ></navigationHeTong>
      <div class="boxsty zhiBiao" v-if="zhiShow == 1">
        <div :height="searchheight">
          <span
            style="float: right; margin-top: -30px; cursor: pointer"
            @click="searchchangeadvanced"
            >{{ searchadvanced ? "查询条件收起" : "查询条件展开" }}
            <i
              :class="
                searchadvanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'
              "
            />
          </span>
          <div v-show="searchadvanced">
            <el-form
              :inline="true"
              :model="dataForm"
              @keyup.enter.native="getDataList()"
              class="form-inline"
              label-width="120px"
            >
              <el-form-item label="合同名称">
                <el-input
                  style="width: 150px"
                  v-model="dataForm.contractName"
                  placeholder="合同名称"
                  :clearable="true"
                ></el-input>
              </el-form-item>
              <el-form-item label="受约人姓名">
                <el-input
                  v-model="dataForm.shouyueName"
                  placeholder="受约人姓名"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="受约人岗位">
                <el-input
                  v-model="dataForm.shouyueZhiwu"
                  placeholder="受约人岗位"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="受约人职级">
                <el-input
                  style="width: 150px"
                  v-model="dataForm.ryZjmc"
                  placeholder="受约人职级"
                  :clearable="true"
                ></el-input>
              </el-form-item>
              <el-form-item label="发约人姓名">
                <el-input
                  v-model="dataForm.fayueName"
                  placeholder="发约人姓名"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="指标审核状态">
                <el-select
                  style="width: 150px"
                  v-model="dataForm.quotaauditStatus"
                  placeholder="请选择"
                  :clearable="true"
                >
                  <el-option value="3" label="填报中"></el-option>
                  <el-option value="2" label="已审核"></el-option>
                  <el-option value="1" label="审核中"></el-option>
                  <el-option value="0" label="未填报"></el-option>
                  <el-option value="10" label="已结束"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="合同状态">
                <el-select
                  style="width: 150px"
                  v-model="dataForm.contractAuditStatus"
                  placeholder="请选择"
                  :clearable="true"
                >
                  <el-option value="" label="全部"></el-option>
                  <el-option value="0" label="创建中"></el-option>
                  <el-option value="1" label="指标填报中"></el-option>
                  <el-option value="2" label="汇总中"></el-option>
                  <el-option value="3" label="汇总完成"></el-option>
                  <el-option value="4" label="文本审核中"></el-option>
                  <el-option value="5" label="文本审核退回"></el-option>
                  <el-option value="6" label="文本审核通过"></el-option>
                  <el-option value="7" label="受约人审核中"></el-option>
                  <el-option value="67" label="受约人驳回"></el-option>
                  <el-option
                    value="78"
                    label="绩效考核办公室审核中"
                  ></el-option>
                  <el-option value="8" label="发约人审核中"></el-option>
                  <el-option value="9" label="签订完成"></el-option>
                  <el-option value="10" label="履约中"></el-option>
                  <el-option value="11" label="结果填报中"></el-option>
                  <el-option value="111" label="填报审核驳回"></el-option>
                  <el-option value="12" label="结果填报审核中"></el-option>
                  <el-option value="13" label="结果汇总完成"></el-option>
                  <el-option value="14" label="领导审核中"></el-option>
                  <el-option value="15" label="领导审核完成"></el-option>
                  <el-option value="16" label="已结束"></el-option>
                </el-select>
              </el-form-item>

              <el-form-item>
                <el-button
                  icon="el-icon-search"
                  type="primary"
                  class="marginLeft"
                  @click="getDataList(1)"
                  >检索
                </el-button>
              </el-form-item>
            </el-form>
          </div>
        </div>
        <div style="height: 50px; border-bottom: 1px solid #b0bde2">
          <el-tooltip
            class="item"
            effect="dark"
            content="导入一个合同"
            placement="top"
          >
            <el-button
              icon="el-icon-upload"
              size="small"
              type="success"
              circle
              @click="openImport"
            ></el-button>
          </el-tooltip>
          <el-tooltip
            class="item"
            effect="dark"
            content="下载合同模板"
            placement="top"
          >
            <el-button
              icon="el-icon-download"
              size="small"
              type="warning"
              circle
              @click="exportWord"
            ></el-button>
          </el-tooltip>
          <el-tooltip
            class="item"
            effect="dark"
            content="新增一个合同"
            placement="top"
            v-model="isShow"
          >
            <el-button
              icon="el-icon-plus"
              type="primary"
              v-if="permissions.hetongrenwu_hetonghtxxdjb_add"
              @click="addOrUpdateHandle()"
              circle
            ></el-button>
          </el-tooltip>
          <el-tooltip
            class="item"
            effect="dark"
            content="打印一个合同"
            placement="top-start"
          >
            <el-button
              type="info"
              icon="el-icon-printer"
              @click="print()"
              circle
            ></el-button>
          </el-tooltip>
          <el-tooltip
            class="item"
            effect="dark"
            content="批量删除选中的合同"
            placement="top-start"
          >
            <el-button
              type="danger"
              icon="el-icon-delete"
              @click="deleteBatch()"
              circle
            ></el-button>
          </el-tooltip>
          <div class="pull-right">
            <el-button
              type="primary"
              plain
              @click="ndts()"
              v-loading.fullscreen.lock="fullscreenLoadingnd"
              >拟定推送</el-button
            >
            <el-button
              type="primary"
              plain
              @click="getHtWeight()"
              v-loading.fullscreen.lock="fullscreenLoadingwb"
              >推送文本</el-button
            >
            <el-button type="primary" plain @click="fqqd()">发起签订</el-button>
            <el-button type="primary" plain @click="guidang()">归档</el-button>
            <el-button plain type="primary" @click="exportExcelZblist"
              >指标跟踪导出</el-button
            >
          </div>
        </div>
        <div class="avue-crud">
          <div class="flex">
            <div class="mt10">
              业绩合同
              <span>
                <el-radio v-model="radio" label="1">个人</el-radio>
                <el-radio v-model="radio" label="2">机构</el-radio>
              </span>
              <span
                style="margin-left: 160px"
                v-if="permissions.hetongrenwu_hetonghtxxdjb_scope"
              >
                数据范围
                <el-radio-group v-model="radioTwo">
                  <el-radio
                    v-for="(item, index) in radioTwoList"
                    :key="index"
                    :label="item.value"
                    >{{ item.name }}</el-radio
                  >
                </el-radio-group>
              </span>
            </div>
          </div>
          <el-table
            ref="table"
            style="width: 100%; margin-top: 20px"
            :data="dataList"
            border
            v-loading="dataListLoading"
            v-if="rednermsg"
            @row-click="unfoldBtn"
          >
            <el-table-column
              type="selection"
              width="55"
              header-align="center"
              align="center"
            ></el-table-column>
            <el-table-column
              type="index"
              width="60"
              header-align="center"
              align="center"
              label="序号"
            ></el-table-column>
            <el-table-column
              prop="contractName"
              header-align="center"
              align="center"
              min-width="200"
              show-overflow-tooltip
              label="合同名称"
            >
              <template slot-scope="scope">
                <span
                  v-if="permissions.hetongrenwu_hetonghtxxdjb_edit"
                  @click="addOrUpdateHandle(scope.row)"
                  style="color: #0e258c; cursor: pointer"
                  >{{ scope.row.contractName }}</span
                >
                <span v-else>{{ scope.row.contractName }}</span>
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 2"
              prop="jigouName"
              header-align="center"
              show-overflow-tooltip
              align="center"
              label="机构名称"
            >
              <template slot-scope="scope">
                <span>{{ scope.row.jigouName }}</span>
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 1"
              prop="shouyueCode"
              header-align="center"
              align="center"
              min-width="150"
              label="受约人编号"
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.shouyueCode.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(scope.row.shouyueCode).slice(
                    0,
                    2
                  )"
                  :key="index"
                >
                  <el-badge
                    :value="cutout(scope.row.shouyueCode).length"
                    :max="9"
                    v-if="
                      cutout(scope.row.shouyueCode).length > 2 && index === 0
                    "
                    class="itembadge"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 1"
              prop="shouyueName"
              header-align="center"
              align="center"
              min-width="150"
              label="受约人姓名"
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.shouyueName.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(scope.row.shouyueName).slice(
                    0,
                    2
                  )"
                  :key="index"
                >
                  <el-badge
                    :value="cutout(scope.row.shouyueName).length"
                    :max="9"
                    v-if="
                      cutout(scope.row.shouyueName).length > 2 && index === 0
                    "
                    class="itembadge"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 1"
              prop="shouyueDeptName"
              header-align="center"
              align="center"
              min-width="150"
              label="受约人单位"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.shouyueDeptName.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(
                    scope.row.shouyueDeptName
                  ).slice(0, 2)"
                  :key="index"
                >
                  <el-badge
                    :value="cutout(scope.row.shouyueDeptName).length"
                    :max="9"
                    v-if="
                      cutout(scope.row.shouyueDeptName).length > 2 &&
                      index === 0
                    "
                    class="itembadge"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 1 && shows == 1"
              prop="shouyueZhiwu"
              header-align="center"
              align="center"
              min-width="170"
              label="受约人岗位"
              show-overflow-tooltip
            >
              <template slot="header">
                <el-tooltip placement="top" content="点击切换至受约人职级">
                  <span
                    ><i
                      @click="switchBtn(2)"
                      class="el-icon-refresh"
                      style="margin-right: 20px"
                    ></i
                    >受约人岗位</span
                  >
                </el-tooltip>
              </template>
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.shouyueZhiwu.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(scope.row.shouyueZhiwu).slice( 0,2
                  )"
                  :key="index"
                >
                  <el-badge
                    :value="cutout(scope.row.shouyueZhiwu).length"
                    :max="9"
                    v-if="
                      cutout(scope.row.shouyueZhiwu).length > 2 && index === 0
                    "
                    class="itembadge"
                  >
                    <span>{{ item | ellipsis }}</span>
                  </el-badge>
                  <span v-else>{{ item | ellipsis }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 1 && shows == 2"
              prop="ryZjmc"
              header-align="center"
              align="center"
              min-width="170"
              label="受约人职级"
            >
              <template slot="header">
                <el-tooltip placement="top" content="点击切换至受约人岗位">
                  <span
                    ><i
                      @click="switchBtn(1)"
                      class="el-icon-refresh"
                      style="margin-right: 20px"
                    ></i
                    >受约人职级</span
                  >
                </el-tooltip>
              </template>
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.ryZjmc.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(scope.row.ryZjmc).slice(0, 2)"
                  :key="index"
                >
                  <el-badge
                    :value="cutout(scope.row.ryZjmc).length"
                    :max="9"
                    v-if="cutout(scope.row.ryZjmc).length > 2 && index === 0"
                    class="itembadge"
                  >
                    <span>{{ item | ellipsis }}</span>
                  </el-badge>
                  <span v-else>{{ item | ellipsis }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              prop="fayueName"
              header-align="center"
              align="center"
              min-width="150"
              label="发约人姓名"
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.fayueName.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(scope.row.fayueName).slice(
                    0,
                    2
                  )"
                  :key="index"
                >
                  <el-badge
                    :value="cutout(scope.row.fayueName).length"
                    :max="9"
                    v-if="cutout(scope.row.fayueName).length > 2 && index === 0"
                    class="itembadge"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              prop="fayueZhiwu"
              header-align="center"
              align="center"
              min-width="180"
              label="发约人岗位"
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.fayueZhiwu.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-for="(item, index) in cutout(scope.row.fayueZhiwu).slice(
                    0,
                    2
                  )"
                  :key="index"
                >
                  <el-tooltip
                    class="item"
                    :disabled="
                      item.length < 8 && cutout(scope.row.fayueZhiwu).length < 3
                    "
                    effect="dark"
                    :content="scope.row.fayueZhiwu.replace(/,/g, '\r\n')"
                    placement="top-start"
                  >
                    <span>{{
                      (validatenull(item) ? "-" : item) | ellipsis
                    }}</span>
                  </el-tooltip>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              prop="weight"
              header-align="center"
              align="center"
              min-width="70"
              label="权重"
            >
              <template slot-scope="scope">
                <span
                  :style="{ color: scope.row.weight !== '100.0' ? 'red' : '' }"
                  >{{ scope.row.weight }}</span
                >
              </template>
            </el-table-column>
            <el-table-column
              prop="quotaauditStatus"
              header-align="center"
              align="center"
              min-width="120"
              label="指标审核状态"
            >
              <template slot-scope="scope">
                <el-popover placement="top" width="240" trigger="hover">
                  <p></p>
                  <div
                    v-for="(item, index) in cutout(
                      scope.row.quotaauditStatusstr
                    )"
                    :key="index"
                  >
                    <el-badge
                      v-if="scope.row.quotaauditStatus != '0'"
                      :value="item.split('-')[1]"
                      :max="9"
                      class="itembadge"
                    >
                      <span
                        v-if="item.indexOf('已完成') != -1"
                        style="color: #0bbf4a"
                        >{{ item.split("-")[0] }}</span
                      >
                      <span
                        v-else-if="item.indexOf('未完成') != -1"
                        style="color: red"
                        >{{ item.split("-")[0] }}</span
                      >
                      <span v-else>{{ item.split("-")[0] }}</span>
                    </el-badge>
                    <span v-else>{{ item.split("-")[0] }}</span>
                  </div>
                  <div slot="reference" class="name-wrapper">
                    <span v-if="scope.row.quotaauditStatus == 0">未填报</span>
                    <span v-else-if="scope.row.quotaauditStatus == 3"
                      >填报中</span
                    >
                    <span v-else-if="scope.row.quotaauditStatus == 1"
                      >审核中</span
                    >
                    <span v-else-if="scope.row.quotaauditStatus == 2"
                      >已审核</span
                    >
                    <span v-else-if="scope.row.quotaauditStatus == 10"
                      >已结束</span
                    >
                  </div>
                </el-popover>
              </template>
            </el-table-column>
            <el-table-column
              prop="contractAuditStatus"
              header-align="center"
              align="center"
              width="140"
              label="合同状态"
            >
              <template slot-scope="scope">
                <div>
                  <el-popover placement="top" width="660" trigger="hover">
                    <el-table :data="scope.row.gridData" max-height="400">
                      <el-table-column
                        width="260"
                        property="NAME_"
                        label="任务名称"
                        show-overflow-tooltip
                      ></el-table-column>
                      <el-table-column
                        width="120"
                        property="ry_name"
                        label="处理人"
                        show-overflow-tooltip
                      ></el-table-column>
                      <el-table-column
                        width="120"
                        property="START_TIME_"
                        label="开始时间"
                        show-overflow-tooltip
                      ></el-table-column>
                      <el-table-column
                        width="120"
                        property="END_TIME_"
                        label="结束时间"
                        show-overflow-tooltip
                      ></el-table-column>
                    </el-table>
                    <span
                      slot="reference"
                      v-html="cutout2(scope.row.contractAuditStatus)"
                    ></span>
                    <el-button
                      type="primary"
                      icon="el-icon-search"
                      @click="showMessage(scope.row.proceid)"
                      >流程跟踪</el-button
                    >
                  </el-popover>
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="avue-crud__pagination">
          <el-pagination
            @size-change="sizeChangeHandle"
            @current-change="currentChangeHandle"
            :current-page="pageIndex"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSize"
            :total="totalPage"
            background
            layout="total, sizes, prev, pager, next, jumper"
          >
          </el-pagination>
        </div>
      </div>
      <!-- 弹窗, 新增 / 修改 -->
      <HeTongForm
        v-if="addOrUpdateVisible"
        ref="addOrUpdate"
        @refreshDataList="getDataList"
        @openZhibiao="openZhibiao"
        @refreash="refreashdata"
      ></HeTongForm>
      <!-- 编辑-->
      <zhibiaoForm
        ref="zhibiaoRef"
        v-if="zhiShow == 2"
        :zhibiaoForm="zhibiaoForm"
        v-on:zhibiaoChild="zhibiaoChild"
        :hetongId="hetongId"
        :contractName="contractName"
      ></zhibiaoForm>
    </basic-container>
    <el-dialog
      title="合同权重(%)"
      :close-on-click-modal="false"
      :visible.sync="sumweight"
      append-to-body
    >
      <div style="height: 30vh">
        <div>
          <el-form ref="form" label-width="120px">
            <el-row>
              <el-col v-for="(item, index) in sumweightList" :key="index">
                <el-col :span="8">
                  <el-form-item label=" 合同名称: ">
                    <span style="font-weight: bold">{{
                      item.contractName
                    }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="合同权重值为: ">
                    <span style="color: red; font-weight: bold">
                      {{ item.weight }}%</span
                    >
                  </el-form-item>
                </el-col>
              </el-col>
            </el-row>
          </el-form>
        </div>
        <span> </span>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-tooltip
          class="item"
          effect="dark"
          content="是否要继续推送文本审核？"
          placement="top"
        >
          <el-button type="primary" @click="openSubmitAllDialog()"
            >推送文本</el-button
          >
        </el-tooltip>
        <el-button type="primary" plain @click="sumweight = false"
          >返回</el-button
        >
      </span>
    </el-dialog>
    <el-dialog
      title="签订审批"
      :visible.sync="faqtdialogVisible"
      width="30%"
      :show-close="false"
    >
      <el-checkbox-group v-model="choosesign" @change="groupChange">
        <el-checkbox
          v-for="item in signedList"
          :label="item.name"
          :key="item.value"
          style="width: 100%"
          >{{ item.name }}</el-checkbox
        >
      </el-checkbox-group>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="approvalBtn">确 定</el-button>
        <el-button @click="faqtdialogVisible = false">取 消</el-button>
      </span>
    </el-dialog>
    <el-dialog :visible.sync="prompt" title="提示" width="30%">
      <div>
        <i style="color: #d97135; font-size: 32px" class="el-icon-warning"></i
        ><span style="line-height: 32px">是否直接汇总？</span>
      </div>
      <div style="text-align: right">
        <el-button
          type="primary"
          @click="yesBtn"
          v-loading.fullscreen.lock="fullscreenLoading"
          >是</el-button
        >
        <el-button @click="noBtn">否</el-button>
      </div>
    </el-dialog>
    <UserCommonSelect
      v-if="usercomment"
      ref="usercomment"
      @refreshDataList="getDataList"
      @submitfy="submitfy"
    ></UserCommonSelect>
    <check-user-all
      ref="checkUserAll"
      :multiple="false"
      :roleCode="roleCode"
      :userIds="userAllIds"
      @getUserList="getDataList"
    ></check-user-all>
    <sortingPerChooseDialog
      :sortingPerChooseDialogData="sortingPerChooseDialogData"
      @sortingPerChooseDialogChild="sortingPerChooseDialogChild"
    ></sortingPerChooseDialog>
    <processTracking
      ref="processTracking"
      @processTrackingChildren="getDataList"
    ></processTracking>
    <AllTreeSelect
      ref="usercommenttree"
      @submitfy="submitfytree"
    ></AllTreeSelect>
    <el-dialog
      title="合同导入"
      :visible.sync="importVisible"
      :show-close="false"
    >
      <el-form
        :model="importForm"
        ref="importForm"
        :rules="dataRule"
        label-width="140px"
      >
        <el-row style="display: flex; justify-content: space-between">
          <el-col :span="12" style="margin-top: 20px">
            <el-form-item label="签订级别:" prop="signLevel">
              <el-select
                class="xiaLa"
                v-model="importForm.signLevel"
                placeholder="请选择签订级别"
                style="width: 100%"
                :clearable="true"
              >
                <el-option
                  v-for="(item, index) in qdjbList"
                  :key="index"
                  :label="item.name"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="考核周期:" prop="contractCycle">
              <el-select
                v-model="importForm.contractCycle"
                placeholder="请选择考核周期"
                class="xiaLa"
                style="width: 100%"
                :clearable="true"
              >
                <el-option
                  v-for="(item, index) in htzqList"
                  :key="index"
                  :label="item.name"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="模板名称:" prop="templateId">
              <el-select
                v-model="importForm.templateId"
                placeholder="模板名称"
                class="xiaLa"
                style="width: 100%"
                :clearable="true"
              >
                <el-option
                  v-for="(item, index) in categoryList"
                  :key="index"
                  :label="item.templateName"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col
            :span="12"
            style="display: flex; justify-content: flex-end"
            class="importantBg"
          >
            <el-upload
              ref="upload"
              action=""
              :headers="headers"
              :data="importForm"
              multiple
              :file-list="fileList"
              :before-upload="handleBefore"
              :on-success="handleSuccess"
              :http-request="httpRequest"
              accept=".docx"
            >
              <el-button
                icon="el-icon-upload"
                type="success"
                style="margin-right: 93px"
                >导入合同文件</el-button
              >
            </el-upload>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button
          type="primary"
          plain
          @click="uploadBtn('importForm')"
          v-loading.fullscreen.lock="fullscreenLoading"
          >保 存</el-button
        >
        <el-button @click="importVisible = false">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import UserCommonSelect from "@/views/hetongrenwu/hetong/hetongyeji/hetonghtxxdjb/formulateDialog";
import {
  getNiDingList,
  Htongndts,
  tuisongwenben,
  faqiqianding,
  deleteBatchHtcj,
  faqiguidang,
  getStepInfo,
  effective,
} from "@/api/hetongrenwu/hetongyeji/hetongnd";
import {
  delObj,
  radioTwoList,
  confirmRole,
  confirmZbExist,
  isExistMubiao,
  exportWord,
} from "@/api/hetongrenwu/hetonghtxxdjb";
import TableForm from "./hetonghtxxdjb-form";
import HeTongForm from "@/views/hetongrenwu/components/hetong-form";
import zhibiaoForm from "@/views/hetongrenwu/components/zhibiao-form.vue";
import { page } from "@/api/hetongrenwu/hetongyeji/hetongnd";
import { mapGetters } from "vuex";
import { validatenull } from "@/util/validate";
import {
  exportExcel,
  checkSign,
  exportExcelZbList,
} from "@/api/hetongrenwu/hetongjghz";
import checkUserAll from "@/components/form/compound/selectUser";
import formulateDialog from "./formulateDialog";
import sortingPerChooseDialog from "@/views/hetongrenwu/components/sortingPerChooseDialog.vue";
import store from "@/store";
import processTracking from "./picDialog/processTracking";
import AllTreeSelect from "@/views/hetongrenwu/components/alltree-select";

export default {
  components: {
    TableForm,
    HeTongForm,
    zhibiaoForm,
    checkUserAll,
    formulateDialog,
    sortingPerChooseDialog,
    UserCommonSelect,
    AllTreeSelect,
    processTracking,
  },
  data() {
    return {
      dataRule: {
        signLevel: [
          { required: true, message: "请选择签订级别", trigger: "change" },
        ],
        contractCycle: [
          { required: true, message: "请选择考核周期", trigger: "change" },
        ],
        templateId: [
          { required: true, message: "请选择模板名称", trigger: "change" },
        ],
      },
      categoryList: [],
      importForm: {},
      qdjbList: [
        { name: "一级合同", value: "1" },
        { name: "二级合同", value: "2" },
        { name: "三级合同", value: "3" },
        { name: "四级合同", value: "4" },
        { name: "五级合同", value: "5" },
      ],
      htzqList: [
        { name: "月度", value: "1" },
        { name: "季度", value: "2" },
        { name: "年度", value: "3" },
      ],
      importVisible: false,
      taskId: "",
      headers: {
        Authorization: "Bearer " + store.getters.access_token,
      },
      dataForm: {
        key: "",
      },
      usercomment: false,
      sortingPerChooseDialogData: {},
      roleCode: "",
      userRoleIds: [],
      userAllIds: [],
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      prompt: false,
      active: false,
      active2: false,
      dataListLoading: false,
      fullscreenLoading: false,
      addOrUpdateVisible: false,
      faqtdialogVisible: false,
      fullscreenLoadingnd: false,
      fullscreenLoadingwb: false,
      radio: "1",
      mainId: Number,
      radioTwo: "-1",
      zhiShow: "1",
      hetongId: Number,
      contractName: "",
      zhibiaoForm: {},
      treeOrgData: [],
      ids: [],
      fileList: [],
      file: [],
      times: 0,
      defaultProps: {
        children: "children",
        label: "name",
      },
      confirmTreeData: [
        {
          id: 5,
          label: "二级机构",
        },
      ],
      signedList: [
        {
          name: "受约人、当前登入人、发约人",
          value: "1",
        },
        {
          name: "受约人、发约人",
          value: "2",
        },
        {
          name: "受约人",
          value: "3",
        },
        {
          name: "发约人",
          value: "4",
        },
      ],
      choosesign: [],
      selectedTreeData: [],
      searchadvanced: true,
      searchheight: "0",
      radioTwoList: radioTwoList,
      sumweight: false,
      sumweightList: [],
      objdata: "",
      ryZjmc: "",
      text: "",
      jsonData: "",
      isShow: true,
      flag: 0,
      shows: 1,
      rednermsg: true,
    };
  },
  watch: {
    radio(value) {
      if (value) {
        this.dataList = [];
        this.getDataList();
      }
    },
    radioTwo(value) {
      if (value) {
        this.getDataList();
      }
    },
  },
  filters: {
    ellipsis(value) {
      if (!value) return "";
      if (value.length > 8) {
        return value.slice(0, 8) + "...";
      }
      return value;
    },
  },
  created() {
    let params = this.$route.query;
    if (!validatenull(params)) {
      this.radioTwo = params.radioTwo;
    }
    this.getDataList();
    this.getTreeData();
  },
  computed: {
    ...mapGetters(["permissions"]),
  },
  methods: {
    unfoldBtn(row) {
      row.rowshows = !row.rowshows;
      this.rednermsg = false;
      this.$nextTick(() => {
        this.rednermsg = true;
      });
    },
    exportWord() {
      exportWord().then((response) => {
        this.$message.closeAll();
        this.$message.success("下载成功!");
        let url = window.URL.createObjectURL(new Blob([response.data]));
        let link = document.createElement("a");
        link.style.display = "none";
        link.href = url;
        link.setAttribute("download", "合同模板.docx");
        document.body.appendChild(link);
        link.click();
      });
    },
    // 获取下拉
    fneffective() {
      effective({
        tagName: "业绩合同",
      }).then((res) => {
        this.categoryList = res.data.data;
      });
    },
    openImport() {
      this.importForm = {};
      this.fileList = [];
      this.file = [];
      this.importVisible = true;
      this.fneffective();
    },
    httpRequest(param) {
      this.file.push(param.file); // 一般情况下是在这里创建FormData对象，但我们需要上传多个文件，为避免发送多次请求，因此在这里只进行文件的获取，param可以拿到文件上传的所有信息
      console.log("httpRequest");
    },
    uploadBtn(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.fullscreenLoading = true;
          var upData = new FormData();
          upData.append("signLevel", this.importForm.signLevel);
          upData.append("templateId", this.importForm.templateId);
          upData.append("contractCycle", this.importForm.contractCycle);
          setTimeout(() => {
            this.file.forEach(function (file) {
              // 因为要上传多个文件，所以需要遍历
              upData.append("file", file, file.name);
            });
            this.axios
              .post("/appr-contract/hetonghtcj/importHT", upData)
              .then((res) => {
                this.importVisible = false;
                this.$message.success("导入成功");
                this.getDataList();
                this.fullscreenLoading = false;
              })
              .catch(function (error) {
                console.log(error);
              });
          }, 9000);
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    handleBefore(file) {
      return new Promise((resolve, reject) => {
        var forms = new FormData();
        var configs = {
          headers: {
            "Content-Type": "multipart/form-data",
            Authorization: "Bearer " + store.getters.access_token,
          },
        };
        forms.append("file", file);
        this.axios
          .post("/appr-contract/hetonghtcj/importHTCheck", forms, configs)
          .then((res) => {
            if (res.data.data != null) {
              this.$message.error(res.data.data);
              return reject(false);
            } else {
              return resolve(true);
            }
          });
      });
    },
    handleSuccess() {
      this.importVisible = false;
      this.$message.success("导入成功");
      this.getDataList();
    },
    showMessage(proId) {
      this.$refs.processTracking.init(proId);
    },
    submitfy(data) {
      console.log(data);
      var params = {
        flag: "否",
        shouyue: data.shouyue,
        fayue: data.fayue,
        rows: JSON.stringify(this.$refs.table.selection),
        selectdata: JSON.stringify(data.tableDataUser),
        selectorgdata: JSON.stringify(data.selectorgdata),
      };
      Htongndts(params).then((res) => {
        this.$message.closeAll();
        this.$message.success("拟定推送成功");
        this.prompt = false;
        this.getDataList();
      });
      // if(data.type =='fy'){
      //   this.fayuerendataList = data.tableDataUser;
      // }else if(data.type =='sy'){
      //   ////console.log(JSON.stringify(data.tableDataUser)+"--==shouyue")
      //   this.shouyuerendataList = data.tableDataUser;
      // }else if(data.type =='jg'){
      //   this.jigoudataList = data.tableDataUser;
      // }
    },
    addUser(type) {
      this.usercomment = true;
      this.jsonData = JSON.stringify(this.ids);
      this.$nextTick(() => {
        //console.log("传参："+JSON.stringify(this.jsonData))
        this.$refs.usercomment.init("12", type, this.jsonData, "ndts2");
      });
    },
    searchchangeadvanced() {
      this.searchadvanced = !this.searchadvanced;
      if (this.searchadvanced) {
        this.searchheight = "50";
      }
    },
    // 获取数据列表
    //获取合同列表
    getDataList() {
      this.dataListLoading = true;
      page(
        Object.assign(
          {
            type: this.radio,
            isbenbu: this.radioTwo,
            fayueName: this.dataForm.fayueName,
            fayueZhiwu: this.dataForm.fayueZhiwu,
            shouyueZhiwu: this.dataForm.shouyueZhiwu,
            quotaauditStatus: this.dataForm.quotaauditStatus,
            contractAuditStatus: this.dataForm.contractAuditStatus,
            shouyueName: this.dataForm.shouyueName,
            ryZjmc: this.dataForm.ryZjmc,
            current: this.pageIndex,
            size: this.pageSize,
            contractName: this.dataForm.contractName,
          },
          this.dataForm
        )
      ).then((response) => {
        ////console.log(JSON.stringify(response.data.data.records));
        this.dataList = response.data.data.records;
        this.totalPage = response.data.data.total;
        this.dataListLoading = false;
        this.dataList.forEach((ele) => {
          ele.rowshows = true;
        });
      });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
    groupChange() {
      if (this.choosesign.length > 1) {
        if (this.choosesign.length == 1) {
          ////console.log("变化", this.choosesign[0]);
          this.text = this.choosesign[0];
        } else {
          ////console.log("变化", this.choosesign[1]);
          this.text = this.choosesign[1];
        }
        this.choosesign.shift();
      } else {
        ////console.log("变化", this.choosesign[0]);
        this.text = this.choosesign[0];
      }
    },
    // 新增 / 修改
    addOrUpdateHandle(obj) {
      //判断当前登录角色是否有绩效考核办公室，是的话才可以新增
      confirmRole().then((response) => {
        if (response.data.data) {
          if (obj != undefined) {
            this.addOrUpdateVisible = true;
            var params = {
              enter: 0,
              disabled: true,
              formName: "htcj",
              isHideBtn: obj.contractAuditStatus > 1 ? true : false,
              hetongId: obj.id,
              contractName: obj.contractName,
              contractAuditStatus: obj.contractAuditStatus,
              taskDefKey: "",
            };
            this.$nextTick(() => {
              this.$refs.addOrUpdate.init(obj, params);
            });
          } else {
            this.addOrUpdateVisible = true;
            this.$nextTick(() => {
              this.$refs.addOrUpdate.init(obj);
            });
          }
        } else {
          this.$message.closeAll();
          this.$message.success("当前登录用户不属于合同管理员，无法新增！");
        }
      });
    },
    // 删除
    deleteHandle(id) {
      this.$confirm("是否确认删除ID为" + id, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return delObj(id);
        })
        .then((data) => {
          this.$message.closeAll();
          this.$message.success("删除成功");
          this.getDataList();
        });
    },
    //子集信息
    zhibiaoChild(zhibiaoChild) {
      if (zhibiaoChild == 1) {
        this.zhiShow = 1;
        this.getDataList();
      }
      if (zhibiaoChild == "关闭") {
        this.zhiShow = 1;
        this.getDataList();
      }
    },
    //确定选择选中得机构
    fnConfirmSelectedData() {
      this.confirmTreeData = this.selectedTreeData;
    },
    //树结构选中的数据
    handleCheckChange(data) {
      var index = this.selectedTreeData.findIndex(
        (item) => item.deptId == data.deptId
      );
      if (index == -1) {
        this.selectedTreeData.push(data);
      } else {
        this.selectedTreeData.splice(index, 1);
      }
    },
    //新增子集返回的数据(关闭修改页面，打开指标库维护)
    openZhibiao(data) {
      this.addOrUpdateVisible = false;
      this.zhiShow = 2;
      this.zhibiaoForm = {
        enter: 0,
        disabled: false,
      };
    },
    switchBtn(e) {
      this.shows = e;
      this.rednermsg = false;
      this.$nextTick(() => {
        this.rednermsg = true;
      });
    },
    //获取树结构
    getTreeData() {
      getNiDingList().then((res) => {
        ////console.log("数：" + JSON.stringify(res));
        this.treeOrgData = res.data.data;
      });
    },
    getHtWeight() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.closeAll();
        this.$message.error("请选择一个合同！");
        return;
      }

      for (var i = 0; i < data.length; i++) {
        if (
          data[i].contractAuditStatus != 3 &&
          data[i].contractAuditStatus != 5
        ) {
          this.$message.closeAll();
          this.$message.error(
            "第" + (i + 1) + "条合同未汇总完成，不允许推送文本审核！"
          );
          return;
        } else if (data[i].templateName != data[0].templateName) {
          this.$message.closeAll();
          this.$message.error("请选择相同模板类型的合同一起推送！");
          return;
        }
        this.mainId = data[i].templateId;
      }
      this.$confirm("是否会签审批？", "提示", {
        confirmButtonText: "是",
        cancelButtonText: "否",
        type: "warning",
      })
        .then((res) => {
          this.flag = 1;
          this.$nextTick(() => {
            this.$refs.usercommenttree.init();
          });
        })
        .catch(() => {
          this.flag = 0;
          this.$nextTick(() => {
            this.$refs.usercommenttree.init();
          });
        });

      // if (mainId) {
      //  var params = {
      //     rows: data,
      //     istemplate: 1,
      //     templateId: mainId,
      //     userId:""
      //   };
      //   this.fullscreenLoadingwb = true;
      //   tuisongwenben(params).then((res) => {
      //     this.$message.closeAll();
      //     this.$message.success("推送成功");
      //     this.fullscreenLoadingwb = false;
      //     this.getDataList();
      //   });
      // } else {
      //   this.fullscreenLoadingwb = true;
      //   getHtWeight({ rows: data }).then((res) => {
      //     this.fullscreenLoadingwb = false;
      //     this.sumweight = true;
      //     this.sumweightList = res.data.data;
      //   });
      // }
      //查询合同权重值
    },
    submitfytree(data) {
      var userStr = "";
      data.tableDataUser.forEach((ele) => {
        userStr = userStr + ele.userId + ",";
      });
      var params = {
        rows: this.$refs.table.selection,
        istemplate: 0,
        sonhq: userStr,
        objdata: this.flag,
      };
      this.fullscreenLoadingwb = true;
      tuisongwenben(params)
        .then((res) => {
          this.$message.closeAll();
          this.$message.success("推送成功");
          this.fullscreenLoadingwb = false;
          this.getDataList();
        })
        .catch((res) => {
          this.fullscreenLoadingwb = false;
        });
    },
    openSubmitAlltg(e) {},
    openSubmitAllDialog() {
      var objv = "";
      this.$confirm("是否会签审批？", "提示", {
        confirmButtonText: "是",
        cancelButtonText: "否",
        type: "warning",
      })
        .then((res) => {
          objv = 1;
        })
        .catch(() => {
          objv = 0;
        })
        .then(() => {
          this.objdata = objv;
          this.sumweight = false;
          this.sortingPerChooseDialogData = {
            visible: true,
            objdata: this.objdata,
            rows: this.$refs.table.selection,
            types: "wbsh",
          };
        });
    },
    fqqd() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.closeAll();
        this.$message.error("请选择一个合同！");
        return;
      }
      //console.log(data)
      var temName = "";
      for (var i = 0; i < data.length; i++) {
        if (
          data[i].contractAuditStatus != 6 &&
          data[0].contractAuditStatus != 67
        ) {
          this.$message.closeAll();
          this.$message.error(
            "第" + (i + 1) + "条合同文本审核未完成，不允许发起签订！"
          );
          return;
        }
        if (data[i].templateName != data[0].templateName) {
          this.$message.closeAll();
          this.$message.error("请选择相同模板类型的合同一起推送！");
          return;
        }
        temName = data[i].templateName;
      }
      if (temName) {
        var params = {
          rows: data,
          istemplate: 1,
        };
        faqiqianding(params).then((res) => {
          this.$message.closeAll();
          this.$message.success("操作成功！");
          this.getDataList();
        });
      } else {
        this.faqtdialogVisible = true;
        this.active = false;
        this.active2 = false;
        this.choosesign = [];
        this.text = "";
      }
    },
    approvalBtn() {
      var data = this.$refs.table.selection;
      var params = {};
      if (this.text == "受约人、当前登入人、发约人") {
        params = {
          rows: data,
          isqueren: 1,
          isshenhe: 1,
          isqianding: 1,
          ismyself: 1,
          istemplate: 0,
        };
      }
      if (this.text == "受约人、发约人") {
        params = {
          rows: data,
          isqueren: 1,
          isshenhe: 1,
          isqianding: 1,
          ismyself: 0,
          istemplate: 0,
        };
      }
      if (this.text == "受约人") {
        params = {
          rows: data,
          isqueren: 1,
          isshenhe: 1,
          isqianding: 0,
          ismyself: 2,
          istemplate: 0,
        };
      }
      if (this.text == "发约人") {
        params = {
          rows: data,
          isqueren: 1,
          isshenhe: 0,
          isqianding: 2,
          ismyself: 2,
          istemplate: 0,
        };
      }
      if (this.text == "") {
        params = {
          rows: data,
          isqueren: 0,
          isshenhe: 2,
          isqianding: 2,
          ismyself: 2,
          istemplate: 0,
        };
      }
      faqiqianding(params).then((res) => {
        this.$message.closeAll();
        this.$message.success("操作成功！");
        this.getDataList();
      });

      this.faqtdialogVisible = false;
    },
    guidang() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.closeAll();
        this.$message.error("请选择合同进行归档！");
        return;
      }
      var ids = [];
      for (var i = 0; i < data.length; i++) {
        if (data[i].contractAuditStatus != 9) {
          this.$message.closeAll();
          this.$message.error(
            "第" + (i + 1) + "条合同没有签订完成，不能归档！"
          );
          return;
        } else {
          ids.push(data[i].id);
        }
      }
      var idsStr = ids.join(",");
      this.$confirm("是否要归档吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return faqiguidang({ ids: idsStr });
        })
        .then((data) => {
          this.$message.closeAll();
          this.$message.success("归档成功");
          this.getDataList();
        });
    },
    sortingPerChooseDialogChild(data) {
      this.getDataList();
    },
    formulateDialogChild(data) {
      this.getDataList();
    },
    //拟定推送-外面
    ndts() {
      this.ids = [];
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.closeAll();
        this.$message.error("请选择一个合同！");
        return;
      }
      var mainId = "";
      var ids = [];
      for (var i = 0; i < data.length; i++) {
        if (
          data[i].contractAuditStatus != 0 &&
          data[i].contractAuditStatus != 1
        ) {
          this.$message.closeAll();
          this.$message.error(
            "第" + (i + 1) + "条合同不是创建中或指标填报中，不允许拟定推送！"
          );
          return;
        } else if (data[i].templateName != data[0].templateName) {
          this.$message.closeAll();
          this.$message.error("请选择相同模板类型的合同一起推送！");
          return;
        }
        // else if(data[i].templateName == data[0].templateName){
        //    this.$message.error("存在模板");
        // }
        else {
          ids.push(data[i].id);
          mainId = data[i].templateId;
        }
      }
      this.ids = ids;
      var params = {
        ids: ids,
      };
      var params2 = {
        stepName: "指标拟定",
        mainId: mainId,
      };

      // 判断是否有指标，有指标提示是否直接汇总，没有指标直接弹出窗口选人
      confirmZbExist(params).then((res) => {
        if (res.data.data) {
          isExistMubiao(params).then((response) => {
            if (response.data.data) {
              this.fullscreenLoadingnd = true;
              // 判断是否有模板名称
              if (params2.mainId) {
                getStepInfo(params2).then((result) => {
                  var flagtext = "";
                  if (result.data.data.isjump == "true") {
                    flagtext = "是";
                    Htongndts({
                      rows: JSON.stringify(this.$refs.table.selection),
                      flag: flagtext,
                    }).then((con) => {
                      this.$message.closeAll();
                      this.$message.success("拟定推送成功");
                      this.getDataList();
                      this.fullscreenLoadingnd = false;
                    });
                  } else {
                    this.fullscreenLoadingnd = false;
                    (flagtext = "否"), this.noBtn();
                  }
                });
              } else {
                this.prompt = true;
                this.fullscreenLoadingnd = false;
              }
            } else {
              this.$confirm(
                "选中数据存在指标目标值为空或者权重值为空的情况，是否继续提交",
                "提示",
                {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning",
                }
              ).then(() => {
                // 判断是否有模板名称
                if (params2.mainId) {
                  this.fullscreenLoadingnd = true;
                  getStepInfo(params2).then((result) => {
                    var flagtext = "";
                    if (result.data.data.isjump == "true") {
                      flagtext = "是";
                      Htongndts({
                        rows: JSON.stringify(this.$refs.table.selection),
                        flag: flagtext,
                      }).then((con) => {
                        this.$message.closeAll();
                        this.$message.success("拟定推送成功");
                        this.getDataList();
                        this.fullscreenLoadingnd = false;
                      });
                    } else {
                      this.fullscreenLoadingnd = false;
                      (flagtext = "否"), this.noBtn();
                    }
                  });
                } else {
                  this.prompt = true;
                }
              });
            }
          });
        } else {
          this.prompt = false;
          this.addUser("ndts");
        }
      });
    },
    yesBtn() {
      this.fullscreenLoading = true;
      var params = {
        flag: "是",
        rows: JSON.stringify(this.$refs.table.selection),
      };
      Htongndts(params).then((res) => {
        this.fullscreenLoading = false;
        this.$message.closeAll();
        this.$message.success("拟定推送成功");
        this.prompt = false;
        this.getDataList();
      });
    },
    noBtn() {
      this.prompt = false;
      this.addUser("ndts");
    },
    fszbbumen() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.closeAll();
        this.$message.error("请选择一个合同！");
        return;
      }
      if (data[0].contractAuditStatus != 0) {
        this.$message.closeAll();
        this.$message.error("请选择创建中的合同！");
        return;
      }
      this.zbvisible = true;
    },
    //拟定推送-里面
    ts() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.closeAll();
        this.$message.error("请选择一个合同！");
        return;
      }
      if (data.length > 1) {
        this.$message.closeAll();
        this.$message.error("只能选择一个合同！");
        return;
      }
      if (data[0].contractAuditStatus != 0) {
        this.$message.closeAll();
        this.$message.error("请选择创建中的合同！");
        return;
      }
      var ids = this.selectedTreeData.map((item) => {
        return item.deptId;
      });
      if (data[0].quotaauditStatusstr == "未填报") {
        this.$confirm("是否直接汇总？", "提示", {
          confirmButtonText: "是",
          cancelButtonText: "否",
          type: "warning",
        })
          .then((data) => {
            this.$message.closeAll();
            this.$message.success("拟定推送成功");
            this.getDataList();
          })
          .catch(() => {});
        // this.zbvisible=true;
      }
    },
    deleteBatch() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.closeAll();
        this.$message.error("请至少选择一个合同！");
        return;
      }
      var ids = [];
      for (var i = 0; i < data.length; i++) {
        ids.push(data[i].id);
      }
      var idsStr = ids.join(",");
      this.$confirm("是否要删除吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return deleteBatchHtcj({ ids: idsStr });
        })
        .then((data) => {
          this.$message.closeAll();
          this.$message.success("删除成功");
          this.getDataList();
        });
    },
    zbtb() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.closeAll();
        this.$message.error("请选择一个合同！");
        return;
      }
      if (data.length > 1) {
        this.$message.closeAll();
        this.$message.error("只能选择一个合同！");
        return;
      }
      // if(data[0].contractAuditStatus!=0){
      //   this.$message.error("合同状态不是创建中，不允许指标填报！");
      //   return;
      // }
      this.zhiShow = 2;
      this.hetongId = data[0].id;
      this.contractName = data[0].contractName;
      this.zhibiaoForm = {
        enter: 0,
        disabled: true,
        formName: "htcj",
        isHideBtn: data[0].contractAuditStatus > 1 ? true : false,
      };
      this.$nextTick(() => {
        if (
          data[0].contractAuditStatus != 0 &&
          data[0].contractAuditStatus != 1 &&
          data[0].contractAuditStatus != 3 &&
          data[0].contractAuditStatus != 5 &&
          data[0].contractAuditStatus != 6
        ) {
          this.$refs.zhibiaoRef.editLock();
        }
        this.$refs.zhibiaoRef.getDataList();
        var params = {
          isHideBtn: data[0].contractAuditStatus > 1 ? true : false,
        };
        this.$refs.zhibiaoRef.saveForm(Object.assign(data[0]), params);
      });
    },
    refreashdata(data) {
      if (data == 1) {
        this.getDataList();
      }
      if (data == "closeDialog") {
        this.getDataList();
        this.addOrUpdateVisible = false;
      }
    },
    cutout(cellValue) {
      console.log(cellValue)
      if (cellValue) {
        var c = cellValue.split(",");
        console.log(c)
        console.log(c.length)
        if (c.length < 1) {
          c.push("-");
          c.push("-");
        } else if (c.length < 2) {
          c.push("-");
        }
        return c;
      }else{
        var c=[]
         c.push("-");
          c.push("-");
          return c
      }
    },
    cutout2(cellValue) {
      if (cellValue == 0) {
        return "创建中";
      }
      if (cellValue == 1) {
        return "指标填报中";
      }
      if (cellValue == 2) {
        return "汇总中";
      }
      if (cellValue == 3) {
        return "汇总完成";
      }
      if (cellValue == 4) {
        return "文本审核中";
      }
      if (cellValue == 5) {
        return "文本审核退回";
      }
      if (cellValue == 6) {
        return "文本审核通过";
      }
      if (cellValue == 7) {
        return "受约人审核中";
      }
      if (cellValue == 67) {
        return "受约人驳回";
      }
      if (cellValue == 78) {
        return "绩效考核办公室审核中";
      }
      if (cellValue == 8) {
        return "发约人审核中";
      }
      if (cellValue == 9) {
        return "签订完成";
      }
      if (cellValue == 10) {
        return "履约中";
      }
      if (cellValue == 11) {
        return "结果填报中";
      }
      if (cellValue == 111) {
        return "填报审核驳回";
      }
      if (cellValue == 12) {
        return "结果填报审核中";
      }
      if (cellValue == 13) {
        return "结果汇总完成";
      }
      if (cellValue == 14) {
        return "领导审核中";
      }
      if (cellValue == 15) {
        return "领导审核完成";
      }
      if (cellValue == 16) {
        return "已结束";
      }
    },
    //取得空值 增加弹错判断
    getBlankValue(value) {
      let lResult = "";
      if (value === undefined || value === null) {
      } else {
        lResult = value;
      }
      return lResult;
    },
    //判空
    validatenull(val) {
      return validatenull(val);
    },
    exportExcelZblist() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.closeAll();
        this.$message.error("请选择一个合同！");
        return;
      }

      var filename = " 指标明细表" + ".xlsx";
      var ids = [];
      for (var i = 0; i < data.length; i++) {
        ids.push(data[i].id);
      }
      exportExcelZbList({
        ids: ids,
      }).then((response) => {
        this.$message.closeAll();
        this.$message.success("导出成功!");
        let url = window.URL.createObjectURL(new Blob([response.data]));
        let link = document.createElement("a");
        link.style.display = "none";
        link.href = url;
        link.setAttribute("download", filename);
        document.body.appendChild(link);
        link.click();
      });
    },
    print() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.closeAll();
        this.$message.error("请选择一个合同！");
        return;
      }
      var ids = [];
      for (var i = 0; i < data.length; i++) {
        ids.push(data[i].id);
      }
      var filename = "";
      if (ids.length > 1) {
        filename = "业绩合同汇总.zip";
      } else {
        filename = "业绩合同汇总" + data[0].contractName + ".zip";
      }
      checkSign(ids).then((res) => {
        if (res.data.data == "true") {
          this.commDayin(ids, filename);
        } else {
          this.$confirm(res.data.data + ",是否确认导出?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          })
            .then(() => {
              this.commDayin(ids, filename);
            })
            .catch(() => {});
        }
      });
    },
    commDayin(ids, filename) {
      exportExcel({ ids: ids }).then((response) => {
        console.log(response.data);
        this.$message.closeAll();
        this.$message.success("操作成功!");
        let url = window.URL.createObjectURL(new Blob([response.data]));
        let link = document.createElement("a");
        link.style.display = "none";
        link.href = url;
        link.setAttribute("download", filename);
        document.body.appendChild(link);
        link.click();
      });
    },
  },
};
</script>
<style>
.icon-box i {
  margin: 0 8px;
  color: #028ae2;
}

.el-tooltip__popper {
  max-width: 80%;
}

.itembadge {
  margin-top: 10px;
  margin-right: 0px;
}
.inline-block {
  display: inline-block;
}
.bg .el-image-viewer__mask {
  background-color: white;
  opacity: 1;
}
.importantBg {
  width: 45%;
  border-radius: 16px;
  padding: 10px;
  box-shadow: 4px 4px 6px #888888;
  background: #fff;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
}
.importantBg .el-upload-list {
  overflow-y: scroll;
  height: 150px;
}
</style>
